package cn.jbolt.ai.app.config;

import cn.jbolt.util.JSONUtil;
import com.fasterxml.jackson.databind.JsonNode;

/**
 * 知识库回答配置
 */
public class ChatWithKlbNodeConfig {

    /**
     * 是否仅知识库
     */
    private boolean onlyKlb = false;

    /**
     * 知识库查询文本 来源字段
     */
    private String promptField = AppConfigConstant.ATTR_KEY_PROMPT;

    /**
     * 知识库查询结果 来源字段
     */
    private String klbResultField = AppConfigConstant.ATTR_KEY_KLB_RESULT;

    /**
     * 输出的字段名
     */
    private String outputField;

    /**
     * 未匹配到知识库的回答
     */
    private String noMatchReply = "抱歉您的问题无法回答";

    /**
     * 是否显示知识库参考
     */
    private boolean showDocRefers = false;

    public static ChatWithKlbNodeConfig from(JsonNode jsonNode) {
        return JSONUtil.toObject(jsonNode, ChatWithKlbNodeConfig.class);
    }

    public static JsonNode getDefaultConfig() {
        return JSONUtil.toJsonObject(new ChatWithKlbNodeConfig());
    }


    public boolean isOnlyKlb() {
        return onlyKlb;
    }

    public void setOnlyKlb(boolean onlyKlb) {
        this.onlyKlb = onlyKlb;
    }

    public String getPromptField() {
        return promptField;
    }

    public void setPromptField(String promptField) {
        this.promptField = promptField;
    }

    public String getKlbResultField() {
        return klbResultField;
    }

    public void setKlbResultField(String klbResultField) {
        this.klbResultField = klbResultField;
    }

    public String getOutputField() {
        return outputField;
    }

    public void setOutputField(String outputField) {
        this.outputField = outputField;
    }

    public String getNoMatchReply() {
        return noMatchReply;
    }

    public void setNoMatchReply(String noMatchReply) {
        this.noMatchReply = noMatchReply;
    }

    public boolean isShowDocRefers() {
        return showDocRefers;
    }

    public void setShowDocRefers(boolean showDocRefers) {
        this.showDocRefers = showDocRefers;
    }
}
